package cn.youyeku.zsxh.ui.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.youyeku.zsxh.R;
import cn.youyeku.zsxh.Utils.AppConfig;
import cn.youyeku.zsxh.Utils.LogUtils;
import cn.youyeku.zsxh.ui.UIControl;
import cn.youyeku.zsxh.ui.activity.ABS.BaseActivity;



public class SettingActivity extends BaseActivity implements View.OnClickListener {

    //这个必须要在onCreate 前声明
    @BindView(R.id.setting_checkbox_receive)
    CheckBox setting_checkbox_receive;
    @BindView(R.id.setting_checkbox_check_update)
    CheckBox setting_checkbox_check_update;
    @BindView(R.id.setting_checkbox_show_sounds)
    CheckBox setting_checkbox_show_sounds;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.act_settion);
        ButterKnife.bind(this);
        initConfigData();
    }

    private void initConfigData() {
        //对获取的数据进行设置
        setting_checkbox_receive.setChecked(AppConfig.CONF_RECEIVE_MESSAGE);
        setting_checkbox_check_update.setChecked(AppConfig.CONF_CHECK_UPDATE_FIRST);
        setting_checkbox_show_sounds.setChecked(AppConfig.CONF_ENABLE_SOUNDS);
    }



    @OnClick({R.id.setting_ll_check_update, R.id.setting_ll_receive, R.id.setting_ll_show_sounds,R.id.setting_cll_about_ours})
    @Override
    public void onClick(View v) {
        //对进行选择的进行更改并写入
        switch (v.getId()) {
            case R.id.setting_ll_check_update:
                setting_checkbox_check_update.toggle();
                AppConfig.CONF_CHECK_UPDATE_FIRST = setting_checkbox_check_update.isChecked();
                AppConfig.set("CONF_CHECK_UPDATE_FIRST", String.valueOf(AppConfig.CONF_CHECK_UPDATE_FIRST));
                break;
            case R.id.setting_ll_show_sounds:
                setting_checkbox_show_sounds.toggle();
                AppConfig.CONF_ENABLE_SOUNDS = setting_checkbox_show_sounds.isChecked();
                AppConfig.set("CONF_ENABLE_SOUNDS", String.valueOf(AppConfig.CONF_ENABLE_SOUNDS));
                break;
            case R.id.setting_ll_receive:
                setting_checkbox_receive.toggle();
                AppConfig.CONF_RECEIVE_MESSAGE = setting_checkbox_receive.isChecked();
                AppConfig.set("CONF_RECEIVE_MESSAGE", String.valueOf(AppConfig.CONF_RECEIVE_MESSAGE));

                break;
            case R.id.setting_cll_about_ours:
                UIControl.showAboutOurs(getApplicationContext());
                break;

        }

    }
}
